<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>按钮</button>

  <script>
    /**
     * elem.attachEvent()
     *  ● 非标准
     */
    const elem = document.querySelector('button')

    function onClick() {
      console.log('onClick')
    }

    // 注册事件监听
    elem.attachEvent('onclick', onClick)

    // 注销事件监听
    elem.detachEvent('onclick', onClick)
  </script>
</body>

</html>